// const url = require('url');
// const studentDao = require('../dao/studentDao');  // es5

import {queryInfoList} from '../dao/studentDao.js'

const path = new Map();

/**
 * 
 * @param {*} req 请求参数
 * @param {*} res 返回参数
 */
function getAllStudent(req, res) {
  console.log('调用了');
  queryInfoList(function (result) {
    res.writeHead(200);
    res.write(JSON.stringify(result));
    res.end();
  });
}

path.set('/getAllStudent', getAllStudent);

/** post demo 接口
function insertStudent(req, res) {
  const params = req.body; // 获取 post的参数
  studentDao.insertStudent(params.sunNum, params.stuName, params.stuClass, params.age, function (result) {
    //{'Content-Type': 'text/html; charset=utf-8'} 中文
    res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});
    res.write(JSON.stringify(result));
    res.end();
  });
}

path.set('/insertStudent', insertStudent);
*/

// module.exports.path = path;
/**
 * 修改为es6
 */
export {path};